import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lily
 * Date: 2024-11-04
 * Time: 21:16
 */
public class test_3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] s = in.next().toCharArray();
        int n = s.length;

        boolean flag = false;
        for (int i = 1; i < n; i++) {
            if (s[i] != s[0]) {
                flag = true;
                break;
            }
        }

        if (flag) // 不是相同的字符
        {
            flag = false;
            // 判断本⾝是不是回⽂
            int left = 0, right = n - 1;
            while (left < right) {
                if (s[left] == s[right]) {
                    left++;
                    right--;
                } else {
                    flag = true;
                    break;
                }
            }
            if (flag) System.out.println(n);
            else System.out.println(n - 1);
        } else // 是相同字符
        {
            System.out.println(0);
        }
    }
}

